ggsave("subdistricts_scheduled_map.png", width = 14, height = 10, dpi = 300)
scheduled_status_summary <- scheduled_data %>%
count(scheduled_status) %>%
arrange(desc(n))%>%
mutate(percentage = round((n / sum(n)) * 100, 2))
scheduled_status_summary <- scheduled_data %>%
count(scheduled_status) %>%
arrange(desc(n))%>%
mutate(percentage = round((n / sum(n)) * 100, 2))
scheduled_status_summary <- scheduled_status_summary %>%
bind_rows(summarise(scheduled_status_summary, scheduled_status = "Total", n = sum(n), percentage = 100))
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries")%>%
kableExtra::save_kable("scheduled_status_summary.png")
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status == "Fifth Schedule") %>%
select(state_name) %>%
distinct()
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name, scheduled_status) %>%
summarise(count = n(), .groups = 'drop') %>%
pivot_wider(names_from = scheduled_status, values_from = count, values_fill = 0) %>%
rename(Scheduled = `Fifth Schedule`, Not_Scheduled = `Not Scheduled`) %>%
mutate(Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2))
library(tidyr)
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status == "Fifth Schedule") %>%
select(state_name) %>%
distinct()
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name, scheduled_status) %>%
summarise(count = n(), .groups = 'drop') %>%
pivot_wider(names_from = scheduled_status, values_from = count, values_fill = 0) %>%
rename(Scheduled = `Fifth Schedule`, Not_Scheduled = `Not Scheduled`) %>%
mutate(Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2))
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>% kableExtra::save_kable("fifth_schedule_state_summary.png")
states_with_sixth_schedule <- scheduled_data %>%
filter(scheduled_status == "Sixth Schedule") %>%
select(state_name) %>%
distinct()
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_sixth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(
Scheduled = sum(scheduled_status == "Sixth Schedule"),
Not_Scheduled = sum(scheduled_status == "Not Scheduled"),
.groups = 'drop'
) %>%
mutate(
Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2)
)
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_sixth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(
Scheduled = sum(scheduled_status == "Sixth Schedule"),
Not_Scheduled = sum(scheduled_status == "Not Scheduled"),
.groups = 'drop'
) %>%
mutate(
Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2)
)
```{r}
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries")%>%kableExtra::save_kable("sixth_schedule_state_summary.png")
scheduled_map$latest_state_schedule_order <- as.factor(scheduled_map$latest_state_schedule_order)
ggplot() +
geom_sf(data = subset(scheduled_map, scheduled_status %in% c("Fifth Schedule", "Sixth Schedule")), aes(fill = latest_state_schedule_order), color = "darkgrey", size = 0.2) +
geom_sf(data = state_borders, fill = NA, color = "black", size = 1) +
scale_fill_manual(
values = c(
"1955" = "#00008B",
"1972" = "blue",
"1975" = "#4169E1",
"1977" = "#ADD8E6",
"1981" = "lightyellow",
"1985" = "yellow",
"1986" = "darkorange",
"2003" = "red",
"2007" = "darkred"
),
breaks = c("1955", "1972", "1975", "1977", "1981", "1985", "1986", "2003", "2007"),
labels = c("1955", "1972", "1975", "1977", "1981", "1985", "1986", "2003", "2007")
) +
theme_minimal() +
theme(legend.position = "right", legend.text = element_text(size=20)) +
labs(
title = "Scheduled Subdistricts by State's Latest Scheduled Area Order Year",
subtitle = "Pratik Mahajan (2024)",
fill = "Scheduled Area Order Year"
) +
theme(
plot.title = element_text(hjust = 0.5, size= 30),
plot.subtitle = element_text(hjust = 0.5, size= 24),
plot.caption = element_text(size = 12),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank()
)
\newpage
ggplot() +
geom_sf(data = subset(scheduled_map, scheduled_status %in% c("Fifth Schedule", "Sixth Schedule")), aes(fill = latest_state_schedule_order), color = "darkgrey", size = 0.2) +
geom_sf(data = state_borders, fill = NA, color = "black", size = 1) +
scale_fill_manual(
values = c(
"1955" = "#00008B",
"1972" = "blue",
"1975" = "#4169E1",
"1977" = "#ADD8E6",
"1981" = "lightyellow",
"1985" = "yellow",
"1986" = "darkorange",
"2003" = "red",
"2007" = "darkred"
),
breaks = c("1955", "1972", "1975", "1977", "1981", "1985", "1986", "2003", "2007"),
labels = c("1955", "1972", "1975", "1977", "1981", "1985", "1986", "2003", "2007")
) +
theme_minimal() +
theme(legend.position = "right", legend.text = element_text(size=20)) +
labs(
title = "Scheduled Subdistricts by State's Latest Scheduled Area Order Year",
subtitle = "Pratik Mahajan (2024)",
fill = "Scheduled Area Order Year"
) +
theme(
plot.title = element_text(hjust = 0.5, size= 30),
plot.subtitle = element_text(hjust = 0.5, size= 24),
plot.caption = element_text(size = 12),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank()
)
ggsave("subdistricts_year_change_in_scheduled_area_map.png", width = 14, height = 10, dpi = 300)
latest_schedule_order_summary <- scheduled_data %>%
filter(state_name %in% states_with_schedule$state_name) %>%
group_by(state_name) %>%
summarise(latest_state_schedule_order = max(latest_state_schedule_order, na.rm = TRUE), .groups = 'drop')%>% arrange(as.numeric(latest_state_schedule_order))
states_with_schedule <- scheduled_data %>%
filter(scheduled_status %in% c("Sixth Schedule", "Fifth Schedule")) %>%
select(state_name) %>%
distinct()
latest_schedule_order_summary <- scheduled_data %>%
filter(state_name %in% states_with_schedule$state_name) %>%
group_by(state_name) %>%
summarise(latest_state_schedule_order = max(latest_state_schedule_order, na.rm = TRUE), .groups = 'drop')%>% arrange(as.numeric(latest_state_schedule_order))
kable(latest_schedule_order_summary, col.names = c("State", "Latest State Schedule Order"), caption = "Latest State Schedule Order for States with Fifth or Sixth Schedule")%>%kableExtra::save_kable("schedule_order_summary.png")
scheduled_map$pesa_first_election_in_state_year <- as.factor(scheduled_map$pesa_first_election_in_state_year)
ggplot() +
geom_sf(data = subset(scheduled_map, scheduled_status == "Fifth Schedule"), aes(fill = pesa_first_election_in_state_year), color = "darkgrey", size = 0.2) +
geom_sf(data = state_borders, fill = NA, color = "black", size = 1) +
scale_fill_manual(
values = c(
"2000" = "#00008B",
"2001" = "#4169E1",
"2002" = "#87CEEB",
"2005" = "orange",
"2007" = "red",
"2010" = "darkred"
),
breaks = c("2000", "2001", "2002", "2005", "2007", "2010"),
labels = c("2000", "2001", "2002", "2005", "2007", "2010")
) +
theme_minimal() +
theme(legend.position = "right", legend.text = element_text(size=20)) +
labs(
title = "Fifth Scheduled Subdistricts by \n State's First PESA Election Year",
subtitle = "Pratik Mahajan (2024)",
fill = "State's First PESA Election Year"
) +
theme(
plot.title = element_text(hjust = 0.5, size= 30),
plot.subtitle = element_text(hjust = 0.5, size= 24),
plot.caption = element_text(size = 12),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank()
)
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status %in% c("Fifth Schedule")) %>%
select(state_name) %>%
distinct()
pesa_first_election_in_state_year_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(pesa_first_election_in_state_year = max(pesa_first_election_in_state_year, na.rm = TRUE), .groups = 'drop')%>% arrange(as.numeric(pesa_first_election_in_state_year))
kable(pesa_first_election_in_state_year_summary, col.names = c("State", "First Election Under PESA Year"), caption = "Fifth Schedule States by Year of First Panchayat Election Under PESA")%>%kableExtra::save_kable("pesa_first_election_in_state_summary.png")
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status %in% c("Fifth Schedule")) %>%
select(state_name) %>%
distinct()
pesa_rules_published_state_year_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(pesa_rules_published_state_year = max(pesa_rules_published_state_year, na.rm = TRUE), .groups = 'drop')%>% arrange(as.numeric(pesa_rules_published_state_year))
kable(pesa_rules_published_state_year_summary, col.names = c("State", "PESA Rules Published Year"), caption = "Fifth Schedule States by Year State Published PESA Rules First Panchayat Election Under PESA")%>%kableExtra::save_kable("pesa_rules_published_state_year_summary.png")
scheduled_map$pesa_rules_published_state_year <- as.factor(scheduled_map$pesa_rules_published_state_year)
ggplot() +
geom_sf(data = subset(scheduled_map, scheduled_status == "Fifth Schedule"), aes(fill = pesa_rules_published_state_year), color = "darkgrey", size = 0.2) +
geom_sf(data = state_borders, fill = NA, color = "black", size = 1) +
scale_fill_manual(
values = c(
"2011" = "#00008B",
"2014" = "#4169E1",
"2017" = "#87CEEB",
"2022" = "yellow",
"Not_Published_by_2024" = "red"
),
breaks = c("2011", "2014", "2017", "2022", "Not_Published_by_2024"),
labels = c("2011", "2014", "2017", "2022", "Not_Published_by_2024")
) +
theme_minimal() +
theme(legend.position = "right", legend.text = element_text(size=20)) +
labs(
title = "Fifth Scheduled Subdistricts by PESA Rules Published \n by State Year, Indicating Wider Implementation",
subtitle = "Pratik Mahajan (2024)",
fill = "Rules Published Year"
) +
theme(
plot.title = element_text(hjust = 0.5, size= 30),
plot.subtitle = element_text(hjust = 0.5, size= 24),
plot.caption = element_text(size = 12),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank()
)
ggsave("subdistricts_state_pesa_rules_publication_year_map.png", width = 14, height = 10, dpi = 300)
e
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 14) %>%
as_image("scheduled_status_summary.png")
library(knitr)
library(kableExtra)
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 14) %>%
as_image("scheduled_status_summary.png")
install.packages("webshot")
install.packages("webshot")
webshot::install_phantomjs()
library(webshot)
library(knitr)
library(kableExtra)
save_kable_as_image <- function(kable_input, file_name) {
temp_file <- tempfile(fileext = ".html")
save_kable(kable_input, temp_file)
webshot(temp_file, file_name, vwidth = 1000, vheight = 500)
}
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 14),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 14),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 14),
"sixth_schedule_state_summary.png"
)
save_kable_as_image(
kable(latest_schedule_order_summary, col.names = c("State", "Latest State Schedule Order"), caption = "Latest State Schedule Order for States with Fifth or Sixth Schedule") %>%
kable_styling(full_width = FALSE, font_size = 14),
"schedule_order_summary.png"
)
save_kable_as_image(
kable(pesa_first_election_in_state_year_summary, col.names = c("State", "First Election Under PESA Year"), caption = "Fifth Schedule States by Year of First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 14),
"pesa_first_election_in_state_summary.png"
)
save_kable_as_image(
kable(pesa_rules_published_state_year_summary, col.names = c("State", "PESA Rules Published Year"), caption = "Fifth Schedule States by Year State Published PESA Rules First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 14),
"pesa_rules_published_state_year_summary.png"
)
library(knitr)
library(kableExtra)
library(webshot)
save_kable_as_image <- function(kable_input, file_name) {
temp_file <- tempfile(fileext = ".html")
save_kable(kable_input, temp_file)
webshot(temp_file, file_name, vwidth = 1400, vheight = 800)
}
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 18),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 18),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 18),
"sixth_schedule_state_summary.png"
)
save_kable_as_image(
kable(latest_schedule_order_summary, col.names = c("State", "Latest State Schedule Order"), caption = "Latest State Schedule Order for States with Fifth or Sixth Schedule") %>%
kable_styling(full_width = FALSE, font_size = 18),
"schedule_order_summary.png"
)
save_kable_as_image(
kable(pesa_first_election_in_state_year_summary, col.names = c("State", "First Election Under PESA Year"), caption = "Fifth Schedule States by Year of First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 18),
"pesa_first_election_in_state_summary.png"
)
save_kable_as_image(
kable(pesa_rules_published_state_year_summary, col.names = c("State", "PESA Rules Published Year"), caption = "Fifth Schedule States by Year State Published PESA Rules First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 18),
"pesa_rules_published_state_year_summary.png"
)
library(knitr)
library(kableExtra)
library(webshot)
save_kable_as_image <- function(kable_input, file_name) {
temp_file <- tempfile(fileext = ".html")
save_kable(kable_input, temp_file)
webshot(temp_file, file_name, vwidth = 1400, vheight = 800)
}
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"sixth_schedule_state_summary.png"
)
save_kable_as_image(
kable(latest_schedule_order_summary, col.names = c("State", "Latest State Schedule Order"), caption = "Latest State Schedule Order for States with Fifth or Sixth Schedule") %>%
kable_styling(full_width = FALSE, font_size = 24),
"schedule_order_summary.png"
)
save_kable_as_image(
kable(pesa_first_election_in_state_year_summary, col.names = c("State", "First Election Under PESA Year"), caption = "Fifth Schedule States by Year of First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 24),
"pesa_first_election_in_state_summary.png"
)
save_kable_as_image(
kable(pesa_rules_published_state_year_summary, col.names = c("State", "PESA Rules Published Year"), caption = "Fifth Schedule States by Year State Published PESA Rules First Panchayat Election Under PESA") %>%
kable_styling(full_width = FALSE, font_size = 24),
"pesa_rules_published_state_year_summary.png"
)
knitr::opts_chunk$set(echo = FALSE)
library(sf)
library(sf)
library(dplyr)
library(ggplot2)
library(ggthemes)
library(ggthemes)
library(patchwork)
library(stringr)
library(knitr)
shape_file <-st_read("subdistrict.shp")
scheduled_data <- read.csv("scheduled_areas_by_subdistrict_india.csv")
scheduled_status_summary <- scheduled_data %>%
count(scheduled_status) %>%
arrange(desc(n))%>%
mutate(percentage = round((n / sum(n)) * 100, 2))
scheduled_status_summary <- scheduled_status_summary %>%
bind_rows(summarise(scheduled_status_summary, scheduled_status = "Total", n = sum(n), percentage = 100))
scheduled_status_summary <- scheduled_data %>%
count(scheduled_status) %>%
arrange(desc(n))%>%
mutate(percentage = round((n / sum(n)) * 100, 2))
scheduled_status_summary <- scheduled_status_summary %>%
bind_rows(summarise(scheduled_status_summary, scheduled_status = "Total", n = sum(n), percentage = 100))
```{r}
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries")
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status == "Fifth Schedule") %>%
select(state_name) %>%
distinct()
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name, scheduled_status) %>%
summarise(count = n(), .groups = 'drop') %>%
pivot_wider(names_from = scheduled_status, values_from = count, values_fill = 0) %>%
rename(Scheduled = `Fifth Schedule`, Not_Scheduled = `Not Scheduled`) %>%
mutate(Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2))
library(tidyr)
states_with_fifth_schedule <- scheduled_data %>%
filter(scheduled_status == "Fifth Schedule") %>%
select(state_name) %>%
distinct()
state_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name, scheduled_status) %>%
summarise(count = n(), .groups = 'drop') %>%
pivot_wider(names_from = scheduled_status, values_from = count, values_fill = 0) %>%
rename(Scheduled = `Fifth Schedule`, Not_Scheduled = `Not Scheduled`) %>%
mutate(Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2))
kable(state_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries")
state_fifth_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_fifth_schedule$state_name) %>%
group_by(state_name, scheduled_status) %>%
summarise(count = n(), .groups = 'drop') %>%
pivot_wider(names_from = scheduled_status, values_from = count, values_fill = 0) %>%
rename(Scheduled = `Fifth Schedule`, Not_Scheduled = `Not Scheduled`) %>%
mutate(Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2))
state_sixth_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_sixth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(
Scheduled = sum(scheduled_status == "Sixth Schedule"),
Not_Scheduled = sum(scheduled_status == "Not Scheduled"),
.groups = 'drop'
) %>%
mutate(
Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2)
)
states_with_sixth_schedule <- scheduled_data %>%
filter(scheduled_status == "Sixth Schedule") %>%
select(state_name) %>%
distinct()
state_sixth_schedule_summary <- scheduled_data %>%
filter(state_name %in% states_with_sixth_schedule$state_name) %>%
group_by(state_name) %>%
summarise(
Scheduled = sum(scheduled_status == "Sixth Schedule"),
Not_Scheduled = sum(scheduled_status == "Not Scheduled"),
.groups = 'drop'
) %>%
mutate(
Total = Scheduled + Not_Scheduled,
Scheduled_Percentage = round((Scheduled / Total) * 100, 2),
Not_Scheduled_Percentage = round((Not_Scheduled / Total) * 100, 2)
)
kable(state_sixth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries")
library(knitr)
library(kableExtra)
library(webshot)
save_kable_as_image <- function(kable_input, file_name) {
temp_file <- tempfile(fileext = ".html")
save_kable(kable_input, temp_file)
webshot(temp_file, file_name, vwidth = 1400, vheight = 800)
}
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(state_sixth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(scheduled_status_summary, col.names = c("Scheduled Status", "Number of Subdistricts", "Percentage"), caption = "Summary of Scheduled Status of Subdistricts as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"scheduled_status_summary.png"
)
save_kable_as_image(
kable(state_sixth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_fifth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"sixth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_fifth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_fifth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Fifth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"fifth_schedule_state_summary.png"
)
save_kable_as_image(
kable(state_sixth_schedule_summary, col.names = c("State", "Scheduled Subdistricts", "Not Scheduled Subdistricts", "Total Subdistricts", "Scheduled (%)", "Not Scheduled (%)"), caption = "Summary of Subdistricts by State for Sixth Schedule as of 2011 Census Boundaries") %>%
kable_styling(full_width = FALSE, font_size = 24),
"sixth_schedule_state_summary.png"
)
